package com.heima.comment.controller;


import com.heima.comment.model.dto.CommentRepayDto;
import com.heima.comment.model.dto.CommentRepayLikeDto;
import com.heima.comment.model.dto.CommentRepayListDto;
import com.heima.comment.service.CommentService;
import com.heima.common.constants.CommentConstants;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/v1/comment_repay")
public class CommentRepayController {

    @Resource
    private CommentService commentService;

    @PostMapping("/load")
    public ResponseResult loadCommentRepay(@RequestBody CommentRepayListDto dto) {
        return commentService.load(dto.getCommentId(),dto.getSize(),dto.getMinDate());
    }

    @PostMapping("/save")
    public ResponseResult saveCommentRepay(@RequestBody CommentRepayDto dto) {
        return commentService.save(dto.getCommentId(), dto.getContent(), CommentConstants.COMMENT_TARGET_COMMENT);
    }

    @PostMapping("/like")
    public ResponseResult saveCommentRepayLike(@RequestBody CommentRepayLikeDto dto) {
        return commentService.like(dto.getCommentRepayId(), dto.getOperation());
    }

}